{
 "cells": [
  {
   "cell_type": "code",
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2025-08-26T02:59:49.009609Z",
     "start_time": "2025-08-26T02:59:48.969865Z"
    }
   },
   "source": [
    "from langchain.chat_models.tongyi import ChatTongyi\n",
    "\n",
    "import os\n",
    "\n",
    "with open(\"api_key.txt\", \"r\") as f:\n",
    "    api_key = f.read()\n",
    "\n",
    "os.environ[\"DASHSCOPE_API_KEY\"] = api_key\n",
    "\n",
    "llm = ChatTongyi(model=\"qwen-plus\")\n",
    "\n",
    "from langchain_tavily import TavilySearch\n",
    "\n",
    "with open(\"./search_api_key\", \"r\") as f:\n",
    "    search_api_key = f.read()\n",
    "\n",
    "os.environ[\"TAVILY_API_KEY\"] = search_api_key\n",
    "\n",
    "from typing import Annotated\n",
    "from typing_extensions import TypedDict\n",
    "\n",
    "from langgraph.graph.message import add_messages\n",
    "\n",
    "class State(TypedDict):\n",
    "    messages: Annotated[list, add_messages]\n",
    "    \n",
    "from langgraph.graph import StateGraph, START, END    \n",
    "\n",
    "graph_builder = StateGraph(State)\n",
    "\n",
    "from langgraph.types import Command, interrupt\n",
    "from langchain_core.tools import tool\n",
    "\n",
    "@tool\n",
    "def human_assistance(query: str) -> str:\n",
    "    \"\"\"Request assistance from a human.\"\"\"\n",
    "    human_response = interrupt({\"query\": query})\n",
    "    return human_response[\"data\"][\"answer\"]\n",
    "\n",
    "tool_search = TavilySearch(max_results=2)\n",
    "tools = [tool_search, human_assistance]\n",
    "\n",
    "llm_tool = llm.bind_tools(tools=tools)\n",
    "\n",
    "def chatbot(state: State):\n",
    "    message = llm_tool.invoke(state[\"messages\"])\n",
    "    assert len(message.tool_calls) <= 1\n",
    "    return {\"messages\": [message]}\n",
    "\n",
    "graph_builder.add_node(\"chatbot\", chatbot)\n",
    "\n",
    "from langgraph.prebuilt import ToolNode, tools_condition\n",
    "\n",
    "tool_node = ToolNode(tools=tools)\n",
    "\n",
    "graph_builder.add_node(\"tools\", tool_node)\n",
    "\n",
    "graph_builder.add_conditional_edges(\n",
    "    \"chatbot\",\n",
    "    tools_condition\n",
    ")\n",
    "\n",
    "graph_builder.add_edge(\"tools\", \"chatbot\")\n",
    "\n",
    "graph_builder.add_edge(START, \"chatbot\")\n",
    "\n",
    "from langgraph.checkpoint.memory import InMemorySaver\n",
    "\n",
    "memory = InMemorySaver()\n",
    "graph = graph_builder.compile(checkpointer=memory)\n",
    "\n",
    "\n"
   ],
   "outputs": [],
   "execution_count": 28
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-26T02:59:53.376929Z",
     "start_time": "2025-08-26T02:59:53.079032Z"
    }
   },
   "cell_type": "code",
   "source": [
    "from IPython.display import Image, display\n",
    "\n",
    "try:\n",
    "    display(Image(graph.get_graph().draw_mermaid_png()))\n",
    "except Exception:\n",
    "    # This requires some extra dependencies and is optional\n",
    "    pass"
   ],
   "id": "30d6e59e48b1d806",
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAANgAAAD5CAIAAADKsmwpAAAAAXNSR0IArs4c6QAAIABJREFUeJztnXlcVNXfx8+dnVlhFnaQRQQBFRSjyBXM3QRzr1+av9K0RUqzrEzTFn20tEwlTCvJFBX3JXNJVAwVEBQQQZF9h2FmmGH2ef6YHuLBAUHnzj3DPe8Xf9y55845n5n5cO73nhUzmUwAgSAaCtECEAiAjIiABWREBBQgIyKgABkRAQXIiAgooBEtADq0akNDpValMKgUeoPepNPaQfMW04FCY2BsHo3No7h4OxAt50nAUDuiGVWLviizpThX2VSjcXRmsHlUNo/GF9J0Gjv4fugsirRGq1LoaQys9K7KL5TrN5DjP5BLtK4egIwITCbTtRONNSWtEi+WXyjHM4BNtKKnQqs2Fue2lN9rrbzfGjVF1G8wj2hF3YLsRrx7XX5hf13UFNHgaCeitVgZhVR37USjSqEf+x9XDh/2GIzURrx8uJ5KB89PkRAtBEeaajVHt1WNmeviHQR1TU9eI/51sE7owhg0wpF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s4Z+80y6+voM4Jn1va7/oJhhm8A3phZMiYKbTMEjiyXJgm2S1SoGL5Z+kWVa36QfL63Q5MLmtGst9ta4Sv7cX7nxStRb49MuYzpIMBj2VauEDenuGLJz3fWfvqi+W+gY70BgwroHRi+kqHh8xTXxoS2VnRuRxhe8vSbKYpNWqGQzLM/0oFCs/AXSmAQCg1WkYdAuLOtBonQa+RoOx/qFsxlu2WL4c0Z6ubCEQ0ftHchvrFTyJhWiJSqUJndwtvc+mWFeDvFo2aoZ1evERPeIxN6CoyWJVQ4uqGa/GbaiQVcu5HGNwJNpriAAeHwnNet+z7FaNTt3LH1yaa1pam1rGzHUmWghJ6VZIvmiDX1FaeS+uF2U1LUCtnL3ci2gh5KVbRsQwbMmmvvLKJnltpyt+2i/ScikDa41dTHy8S2Z60Egxe7mXSGQoTq+Q1/WSzcmklfKCS6W+gbQJ8zsORUbYmJ41pjw/RRQcybt8pLHhgcpEpfMlHHtch6RVrlHUq4wajdidPnFNH6ZDrxrcYKf0uFXPyZkxdZFbTYm6KLvlwe1aJptmNGJUBpVKp1JoVIDbKManAcMwvc5g1Or1WoO2Vcd0oASEcfsNlqCVEeHhCZuXXX1Yrj6s4bFLafUMAAABBUlEQVTiphqtrEGnlOuVMr1BbzToYTQig4VRqBQOn83mU8UeDK7A/mrxXs/T9nMIXRlCV1SvIJ4W1KNqT3AENLte9EDoyuwseENGtCccOJSGSg3RKp4QndZYUagUiC3fP5ER7QmXPiydxl4X5Wmq0XQxxBMZ0Z7w6sfGMHDrol0uVnbx96rnX+x00Xy49mtGdIfLh+t1OpP/QL7I3Q5W1VfK9bJ6zV/7a/7ziTen8/YKZES7JPdvWd41uVpl0OC2MoxVkHgwm+u0vgM4z08Rd72dJTKiHWMyAa0aaiOajCYWp1sdV8iICChADysIKEBGREABMiICCpAREVCAjIiAAmREBBT8LxNhB/DtPHnJAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "execution_count": 29
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-26T03:03:02.806348Z",
     "start_time": "2025-08-26T03:03:01.447694Z"
    }
   },
   "cell_type": "code",
   "source": [
    "user_input = \"我需要一些专家指导来构建人工智能代理。你能为我请求帮助吗\"\n",
    "config2 = {\"configurable\": {\"thread_id\": \"2\"}}\n",
    "\n",
    "events = graph.stream(\n",
    "    {\"messages\": [{\"role\": \"user\", \"content\": user_input}]},\n",
    "    config=config2,\n",
    "    stream_mode=\"values\"\n",
    ")\n",
    "\n",
    "for event in events:\n",
    "    if \"messages\" in event:\n",
    "        event[\"messages\"][-1].pretty_print()"
   ],
   "id": "f397958f60339c5a",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "================================\u001B[1m Human Message \u001B[0m=================================\n",
      "\n",
      "我需要一些专家指导来构建人工智能代理。你能为我请求帮助吗\n",
      "==================================\u001B[1m Ai Message \u001B[0m==================================\n",
      "Tool Calls:\n",
      "  human_assistance (call_6009a63198b54027907b76)\n",
      " Call ID: call_6009a63198b54027907b76\n",
      "  Args:\n",
      "    query: 我需要一些专家指导来构建人工智能代理。你能为我请求帮助吗\n"
     ]
    }
   ],
   "execution_count": 34
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-26T03:03:05.390640Z",
     "start_time": "2025-08-26T03:03:05.371649Z"
    }
   },
   "cell_type": "code",
   "source": [
    "snapshot = graph.get_state(config2)\n",
    "snapshot"
   ],
   "id": "d974838652566063",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "StateSnapshot(values={'messages': [HumanMessage(content='我需要一些专家指导来构建人工智能代理。你能为我请求帮助吗', additional_kwargs={}, response_metadata={}, id='5ce99369-c231-455c-9471-c593b202b58d'), AIMessage(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_29d67c824c1f4847bfac9a', 'type': 'function', 'function': {'name': 'human_assistance', 'arguments': '{\"query\": \"我需要一些专家指导来构建人工智能代理。你能为我请求帮助吗\"}'}}]}, response_metadata={'model_name': 'qwen-plus', 'finish_reason': 'tool_calls', 'request_id': '27b93632-b057-987f-94d6-f998c52dba19', 'token_usage': {'input_tokens': 1874, 'output_tokens': 35, 'total_tokens': 1909, 'prompt_tokens_details': {'cached_tokens': 0}}}, id='run--43f31784-743d-4371-9080-ec1d1d8dca09-0', tool_calls=[{'name': 'human_assistance', 'args': {'query': '我需要一些专家指导来构建人工智能代理。你能为我请求帮助吗'}, 'id': 'call_29d67c824c1f4847bfac9a', 'type': 'tool_call'}]), ToolMessage(content=\"We, the experts are here to help! We'd recommend you check out LangGraph...\", name='human_assistance', id='19bf2c04-f455-4685-89b5-cbba23201686', tool_call_id='call_29d67c824c1f4847bfac9a'), AIMessage(content='构建人工智能代理是一个令人兴奋的项目！有几个关键步骤和考虑因素可以帮助您开始：\\n\\n1. **定义代理的目标**：\\n   - 您希望代理完成什么任务？\\n   - 它是为了解决特定问题、提供客户服务，还是执行自动化任务？\\n\\n2. **选择适当的AI技术**：\\n   - 确定您需要的技术栈，例如自然语言处理（NLP）、机器学习（ML）或深度学习。\\n   - 考虑使用现有的AI框架和平台，如TensorFlow、PyTorch或LangGraph。\\n\\n3. **设计代理的架构**：\\n   - 决定代理的模块化设计，包括感知、决策和行动模块。\\n   - 确保模块之间的通信和数据流是高效的。\\n\\n4. **开发和训练模型**：\\n   - 收集和准备训练数据。\\n   - 训练模型并进行验证和测试，以确保其性能符合预期。\\n\\n5. **集成和部署**：\\n   - 将训练好的模型集成到代理的架构中。\\n   - 部署代理并在实际环境中进行测试。\\n\\n6. **持续监控和优化**：\\n   - 监控代理的性能并根据反馈进行调整。\\n   - 不断优化模型和架构以提高效率和效果。\\n\\n如果您对这些步骤中的任何一部分有更具体的问题，或者需要进一步的指导，请随时提问！我们在这里帮助您完成这个项目。', additional_kwargs={}, response_metadata={'model_name': 'qwen-plus', 'finish_reason': 'stop', 'request_id': 'ac063020-263d-94ad-82e7-ff56af62dae4', 'token_usage': {'input_tokens': 1940, 'output_tokens': 299, 'total_tokens': 2239, 'prompt_tokens_details': {'cached_tokens': 1792}}}, id='run--f09bfacb-51de-4f2e-b570-3e6b2fcc9ef8-0'), HumanMessage(content='我需要一些专家指导来构建人工智能代理。你能为我请求帮助吗', additional_kwargs={}, response_metadata={}, id='43cfdd87-6bde-42af-8a88-40d44e213a2d'), AIMessage(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_6009a63198b54027907b76', 'type': 'function', 'function': {'name': 'human_assistance', 'arguments': '{\"query\": \"我需要一些专家指导来构建人工智能代理。你能为我请求帮助吗\"}'}}]}, response_metadata={'model_name': 'qwen-plus', 'finish_reason': 'tool_calls', 'request_id': '9f250a3b-2962-98a7-bc2f-edf734dffe66', 'token_usage': {'input_tokens': 2265, 'output_tokens': 35, 'total_tokens': 2300, 'prompt_tokens_details': {'cached_tokens': 0}}}, id='run--deada8f6-af5e-40f1-bcfc-a6d445b8fc3e-0', tool_calls=[{'name': 'human_assistance', 'args': {'query': '我需要一些专家指导来构建人工智能代理。你能为我请求帮助吗'}, 'id': 'call_6009a63198b54027907b76', 'type': 'tool_call'}])]}, next=('tools',), config={'configurable': {'thread_id': '2', 'checkpoint_ns': '', 'checkpoint_id': '1f082292-e242-6f07-8006-840e671fdfd9'}}, metadata={'source': 'loop', 'step': 6, 'parents': {}}, created_at='2025-08-26T03:03:02.787866+00:00', parent_config={'configurable': {'thread_id': '2', 'checkpoint_ns': '', 'checkpoint_id': '1f082292-d584-6d53-8005-86b03b9f543d'}}, tasks=(PregelTask(id='37ef0c5c-cf88-0270-edca-7ea879bbb455', name='tools', path=('__pregel_pull', 'tools'), error=None, interrupts=(Interrupt(value={'query': '我需要一些专家指导来构建人工智能代理。你能为我请求帮助吗'}, id='1c2f789c8749d1f4c7b5119d44fb6df6'),), state=None, result=None),), interrupts=(Interrupt(value={'query': '我需要一些专家指导来构建人工智能代理。你能为我请求帮助吗'}, id='1c2f789c8749d1f4c7b5119d44fb6df6'),))"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 35
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-26T03:03:27.075900Z",
     "start_time": "2025-08-26T03:03:07.679128Z"
    }
   },
   "cell_type": "code",
   "source": [
    "human_response = {\n",
    "    \"我们的专家随时为您提供帮助！我们建议您查看 LangGraph 来构建您的代理。\",\n",
    "    \"它比简单的自主代理更加可靠和可扩展。\"\n",
    "}\n",
    "human_command = Command(resume={\n",
    "    \"data\": {\"answer\": human_response}\n",
    "})\n",
    "\n",
    "events = graph.stream(human_command, config2, stream_mode=\"values\")\n",
    "for event in events:\n",
    "    if \"messages\" in event:\n",
    "        event[\"messages\"][-1].pretty_print()"
   ],
   "id": "a50e3920423b7a45",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "==================================\u001B[1m Ai Message \u001B[0m==================================\n",
      "Tool Calls:\n",
      "  human_assistance (call_6009a63198b54027907b76)\n",
      " Call ID: call_6009a63198b54027907b76\n",
      "  Args:\n",
      "    query: 我需要一些专家指导来构建人工智能代理。你能为我请求帮助吗\n",
      "=================================\u001B[1m Tool Message \u001B[0m=================================\n",
      "Name: human_assistance\n",
      "\n",
      "{'我们的专家随时为您提供帮助！我们建议您查看 LangGraph 来构建您的代理。', '它比简单的自主代理更加可靠和可扩展。'}\n",
      "==================================\u001B[1m Ai Message \u001B[0m==================================\n",
      "\n",
      "构建人工智能代理是一个非常有前景的项目！以下是为您定制的指导建议：\n",
      "\n",
      "### 1. **明确代理的目标**\n",
      "   - **任务定义**：您希望代理是专注于特定任务（如客户服务、数据分析）还是具备多用途能力？\n",
      "   - **用户需求**：您的代理是面向个人用户、企业，还是其他场景？明确使用场景将帮助您设计功能。\n",
      "\n",
      "### 2. **技术选型**\n",
      "   - **基础框架**：\n",
      "     - **LangGraph**：这是一个非常推荐的工具，它比简单的自主代理更可靠且可扩展。它允许您构建复杂的对话流程，并支持记忆、状态管理等功能。\n",
      "     - **LangChain**：如果您需要一个灵活的框架来连接不同的AI组件，LangChain 也是不错的选择。\n",
      "     - **Rasa**：如果您专注于对话代理，Rasa 提供了强大的开源框架。\n",
      "   - **AI模型**：\n",
      "     - **大语言模型（LLM）**：您可以使用像 GPT、Llama 或其他开源模型作为代理的“大脑”。\n",
      "     - **机器学习模型**：如果您的代理需要执行特定任务（如图像识别、预测等），可以集成训练好的模型。\n",
      "\n",
      "### 3. **代理架构设计**\n",
      "   - **模块化设计**：\n",
      "     - **感知模块**：负责接收输入（如文本、语音、图像）。\n",
      "     - **决策模块**：基于输入和上下文做出决策，例如调用工具或生成响应。\n",
      "     - **行动模块**：执行具体操作（如调用API、发送消息）。\n",
      "   - **状态管理**：使用像 LangGraph 这样的工具可以帮助您管理代理的状态和对话流程。\n",
      "\n",
      "### 4. **开发与测试**\n",
      "   - **数据准备**：为训练模型准备高质量的数据。如果使用预训练模型，确保对领域数据进行微调。\n",
      "   - **逐步开发**：从简单的功能开始，逐步增加复杂性。例如，先实现基本对话，再加入工具调用。\n",
      "   - **测试与优化**：持续测试代理的表现，优化模型和逻辑。\n",
      "\n",
      "### 5. **部署与扩展**\n",
      "   - **部署方式**：选择适合的部署方式（如本地服务器、云平台或边缘设备）。\n",
      "   - **可扩展性**：确保代理的架构支持未来扩展，例如增加新功能或集成更多工具。\n",
      "\n",
      "### 6. **监控与维护**\n",
      "   - **性能监控**：跟踪代理的使用情况和性能，及时发现并解决问题。\n",
      "   - **用户反馈**：收集用户反馈以改进代理的功能和用户体验。\n",
      "\n",
      "如果您对 LangGraph 感兴趣，可以从它的官方文档入手，了解如何构建状态机和管理对话流程。如果您需要进一步的指导或具体的代码示例，请随时告诉我！\n"
     ]
    }
   ],
   "execution_count": 36
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-26T03:05:03.724275Z",
     "start_time": "2025-08-26T03:05:03.714668Z"
    }
   },
   "cell_type": "code",
   "source": [
    "class State(TypedDict):\n",
    "    messages: Annotated[list, add_messages]\n",
    "    name: str\n",
    "    birthday: str"
   ],
   "id": "bfd58d9ac73cc8f0",
   "outputs": [],
   "execution_count": 37
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-26T02:44:04.010021Z",
     "start_time": "2025-08-26T02:44:04.004056Z"
    }
   },
   "cell_type": "code",
   "source": "",
   "id": "c9246b88eeea965",
   "outputs": [],
   "execution_count": 13
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-26T02:44:14.216632Z",
     "start_time": "2025-08-26T02:44:13.948999Z"
    }
   },
   "cell_type": "code",
   "source": "",
   "id": "bea3615292ef2831",
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAANgAAAD5CAIAAADKsmwpAAAAAXNSR0IArs4c6QAAIABJREFUeJztnXlcVNXfx8+dnVlhFnaQRQQBFRSjyBXM3QRzr1+av9K0RUqzrEzTFn20tEwlTCvJFBX3JXNJVAwVEBQQQZF9h2FmmGH2ef6YHuLBAUHnzj3DPe8Xf9y55845n5n5cO73nhUzmUwAgSAaCtECEAiAjIiABWREBBQgIyKgABkRAQXIiAgooBEtADq0akNDpValMKgUeoPepNPaQfMW04FCY2BsHo3No7h4OxAt50nAUDuiGVWLviizpThX2VSjcXRmsHlUNo/GF9J0Gjv4fugsirRGq1LoaQys9K7KL5TrN5DjP5BLtK4egIwITCbTtRONNSWtEi+WXyjHM4BNtKKnQqs2Fue2lN9rrbzfGjVF1G8wj2hF3YLsRrx7XX5hf13UFNHgaCeitVgZhVR37USjSqEf+x9XDh/2GIzURrx8uJ5KB89PkRAtBEeaajVHt1WNmeviHQR1TU9eI/51sE7owhg0wpFoIbbgWELlsxNFLt4sooV0CkmNeCKxyiuQHTaSFC40c2xHZdBQfmAEpCEjGdsRr51ocPd3IJULAQBTF3tkXZQ2VGmIFmIZ0hmx6JYCADAkprc9mnSHOSu8Lx+uNxlhvAeSzoipKfXho8noQjN+A7hXjz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nRuRxhe8vSbKYpNWqGQzLM/0oFCs/AXSmAQCg1WkYdAuLOtBonQa+RoOx/qFsxlu2WL4c0Z6ubCEQ0ftHchvrFTyJhWiJSqUJndwtvc+mWFeDvFo2aoZ1evERPeIxN6CoyWJVQ4uqGa/GbaiQVcu5HGNwJNpriAAeHwnNet+z7FaNTt3LH1yaa1pam1rGzHUmWghJ6VZIvmiDX1FaeS+uF2U1LUCtnL3ci2gh5KVbRsQwbMmmvvLKJnltpyt+2i/ScikDa41dTHy8S2Z60Egxe7mXSGQoTq+Q1/WSzcmklfKCS6W+gbQJ8zsORUbYmJ41pjw/RRQcybt8pLHhgcpEpfMlHHtch6RVrlHUq4wajdidPnFNH6ZDrxrcYKf0uFXPyZkxdZFbTYm6KLvlwe1aJptmNGJUBpVKp1JoVIDbKManAcMwvc5g1Or1WoO2Vcd0oASEcfsNlqCVEeHhCZuXXX1Yrj6s4bFLafUMAAABBUlEQVTiphqtrEGnlOuVMr1BbzToYTQig4VRqBQOn83mU8UeDK7A/mrxXs/T9nMIXRlCV1SvIJ4W1KNqT3AENLte9EDoyuwseENGtCccOJSGSg3RKp4QndZYUagUiC3fP5ER7QmXPiydxl4X5Wmq0XQxxBMZ0Z7w6sfGMHDrol0uVnbx96rnX+x00Xy49mtGdIfLh+t1OpP/QL7I3Q5W1VfK9bJ6zV/7a/7ziTen8/YKZES7JPdvWd41uVpl0OC2MoxVkHgwm+u0vgM4z08Rd72dJTKiHWMyAa0aaiOajCYWp1sdV8iICChADysIKEBGREABMiICCpAREVCAjIiAAmREBBT8LxNhB/DtPHnJAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "execution_count": 14
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-26T02:44:30.294999Z",
     "start_time": "2025-08-26T02:44:29.120895Z"
    }
   },
   "cell_type": "code",
   "source": "",
   "id": "cfce55e918302555",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "================================\u001B[1m Human Message \u001B[0m=================================\n",
      "\n",
      "I need some expert guidance for building an AI agent. Could you request assistance for me?\n",
      "==================================\u001B[1m Ai Message \u001B[0m==================================\n",
      "Tool Calls:\n",
      "  human_assistance (call_3443ae19ebd440448d81ea)\n",
      " Call ID: call_3443ae19ebd440448d81ea\n",
      "  Args:\n",
      "    query: I need expert guidance for building an AI agent. Can someone assist me with this?\n"
     ]
    }
   ],
   "execution_count": 15
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
